<%--
    Document   : index
    Created on : May 4, 2011, 8:47:16 AM
    Author     : Huynh Ngoc Tin
--%>

<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%
    String resultMessage = (String) request.getAttribute("resultMessage");
    ArrayList authorList = (ArrayList) request.getAttribute("authorList");
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Manage Bibliography DB</title>
<script language="javascript">
function addAuthorClick() {
    found = false;
    var authorList = document.getElementById("authorListId");
    var newAuthorName = document.getElementById("authorNameId").value;
    if (newAuthorName != "") {
        for (i=0;i<authorList.length;i++) {
            if (authorList.options[i].text == newAuthorName) {
                alert('Input author existed in the list');
                found = true;
                break;
            }
        }
        if (found == false) {
            var option=document.createElement("option");
            option.text=document.getElementById("authorNameId").value;
            authorList.add(option, authorList.options[null]);
        }
    }
    else {
        alert("Please enter the author name");
    }
}

function removeAuthorClick() {
    var authorList = document.getElementById("authorListId");
    authorList.remove(authorList.selectedIndex);
}

function onAutoCrawlingClick() {
    var authorList = document.getElementById("authorListId");
    for (i=0;i<authorList.length;i++) {
        authorList.options[i].selected = true;
    }
    document.AutoCrawlForm.submit();
}

</script>
</head>
<body>
<center><h1><font>Automatic Crawling From MAS</font></h1></center>
<%  if ((resultMessage != null) && (!resultMessage.equals(""))) {
%>
<font color="red"><%=resultMessage%></font><br>
<%
    }
%>
<a href="./GoIndexPageServlet">Home</a>&nbsp;&nbsp;&nbsp;
<a href="./GoBibliographyDBBuildingServlet">Build & Enrich CS Publications Bibliography DB</a>&nbsp;&nbsp;&nbsp;
<a href="./GoCoAuthorGraphBuildingServlet">Build Co-Author Network</a>&nbsp;&nbsp;&nbsp;
<a href="./GoProgramCommiteeNetworkBuildingServlet">Build CoAuthor NetWork for Program-Committee</a>&nbsp;&nbsp;&nbsp;
<hr width="100%" size=10 color="#EBEBEB">
<form name="LoadAuthorFromFileForm" action="./LoadAuthorFromFileServlet?action=autocrawl" ENCTYPE="multipart/form-data" method="post">
Load from file:
<input type="file" size="50" name="authorFile" id="authorFile" value="Browse">
<input type="submit" name="loadTextFile" value="Load File">
</form>
<form name="AutoCrawlForm" action="./MASAutoCrawlingServlet" method="post">
<table>
<tr>
    <td>
        <table>
            <tr>
                <td>Author name</td>
                <td><input type="text" name="authorName" id="authorNameId"></td>
            </tr>
            <tr>
                <td>Depth Level</td>
                <td>
                    <select name="depthLevel">
                        <option selected>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>Unlimited</option>
                    </select>
                </td>
            </tr>
        </table>
    </td>
    <td>
        <table>
            <tr><td><input type="button" value=">>" onclick="addAuthorClick()"></td></tr>
            <tr><td><input type="button" value="<<" onclick="removeAuthorClick()"></td></tr>
        </table>
    </td>
    <td>
        <table>
            <tr><td>List of authors</td></tr>
            <tr>
                <td>
                    <select name="authorList" id="authorListId" size="5" style="width: 300px" multiple>
                    <%
                    if (authorList != null && authorList.size() > 0) {
                    for (int i=0; i<authorList.size(); i++) {
                    %>
                        <option><%=(String) authorList.get(i)%></option>                   
                    <%
                    }
                    } 
                    %>
                    </select>
                </td>
            </tr>
        </table>
    </td>
</tr>
</table>
<hr width="100%" size=10 color="#EBEBEB">
<input type="button" value="Auto Crawl&Import into the DB" onclick="onAutoCrawlingClick()">
</form>
</body>
</html>
